/**
 * 
 */
package cl.duocap.refaxion.dao;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.SQLException;

import cl.duocap.refaxion.dto.AuditorioDTO;

/**
 * @author rentonx
 *
 */
public class AuditoriaDAO {

	/**
	 * 
	 */
	private Connection conexion;
	
	public boolean registrarAccion(AuditorioDTO accion){
		
		try {
			
			
			CallableStatement cstmt = conexion.prepareCall("{ call paInsRefaxionAuditoriaRegistrarAccion(?,?,?,?,?,?)}");
	
			int i = 1;
			
			cstmt.setInt(i++,accion.getIdUsuario());
			cstmt.setString(i++,accion.getFechaAccion());
			cstmt.setInt(i++,accion.getEstadoActual());
			cstmt.setInt(i++,accion.getEstadoNuevo());
			cstmt.setString(i++,accion.getItem());
			cstmt.setString(i++,accion.getObservacion());

			cstmt.executeUpdate();
			cstmt.close();
			
			return true;
			
			
		 } catch (SQLException ex) {
	         throw new RuntimeException("error auditoria Ordenes de Trabajo.",ex);   
	         
	    }finally {
	         try{
	        	 conexion.close();
	        	
	        }catch (Exception ex){
	            
	        }
	        try{
	        	
	            conexion.close();
	            
	        }catch (Exception ex){
	            
	        }
	        
	    }
		
		
	}
	
	public AuditoriaDAO() {
		
	}

	public Connection getConexion() {
		return conexion;
	}

	public void setConexion(Connection conexion) {
		this.conexion = conexion;
	}

}
